/*
 * DialogoApuesta.java
 *
 * Created on 4 de abril de 2008, 19:53
 */

package javamus;

/**
 *
 * @author  jose
 */
public class DialogoApuesta extends javax.swing.JDialog {
    MesaSwing pantalla;
    Player jugador;
    /** Creates new form DialogoApuesta */
    public DialogoApuesta(java.awt.Frame parent, boolean modal,MesaSwing p, Player j) {
        
        super(parent, modal);
        pantalla = p;
        jugador = j;
        this.setLocation(100,100);
        initComponents();
        if (pantalla.m.estadoPartida==1){
            this.jTexto1.setText("Jugamos a grandes");
            this.jApuesta.setText(pantalla.m.apuestaGrande + "+" +pantalla.m.apuestaV);
        }
        if (pantalla.m.estadoPartida==2){
                this.jApuesta.setText(pantalla.m.apuestaChica + "+" +pantalla.m.apuestaV);
                this.jTexto1.setText("Jugamos las chicas");
        }
        if (pantalla.m.estadoPartida==3){
            this.jTexto1.setText("Jugamos los pares");
            this.jApuesta.setText(pantalla.m.apuestaPares + "+" +pantalla.m.apuestaV);
        }
        if (pantalla.m.estadoPartida==4){
            this.jTexto1.setText("Jugamos el juego");
            this.jApuesta.setText(pantalla.m.apuestaJuego + "+" +pantalla.m.apuestaV);
        }
        if (this.pantalla.m.apuestaV <=1) this.botonVer.setEnabled(false);
        
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        botonPasar = new javax.swing.JButton();
        spinnerApuesta = new javax.swing.JSpinner();
        botonApostar = new javax.swing.JButton();
        botonVer = new javax.swing.JButton();
        jTexto1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jApuesta = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        botonPasar.setText("Pasar");
        botonPasar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonPasarActionPerformed(evt);
            }
        });

        spinnerApuesta.setOpaque(false);
        spinnerApuesta.setValue(2);

        botonApostar.setText("Apostar");
        botonApostar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonApostarActionPerformed(evt);
            }
        });

        botonVer.setText("Ver");
        botonVer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonVerActionPerformed(evt);
            }
        });

        jTexto1.setFont(new java.awt.Font("DejaVu Sans", 3, 18));
        jTexto1.setText("Jugar a Grandes");

        jLabel1.setText("Apuesta actual:");

        jApuesta.setText("0");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(botonPasar, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botonVer, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botonApostar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spinnerApuesta, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jApuesta))
                            .addComponent(jTexto1, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTexto1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jApuesta))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonPasar)
                    .addComponent(botonApostar)
                    .addComponent(spinnerApuesta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botonVer))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonPasarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonPasarActionPerformed
        // TODO add your handling code here:
        jugador.pasa(pantalla.m);
        this.dispose();
}//GEN-LAST:event_botonPasarActionPerformed

    private void botonVerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonVerActionPerformed
        // TODO add your handling code here:
        if (pantalla.m.estadoPartida==1) jugador.verGrandes(pantalla.m);
        if (pantalla.m.estadoPartida==2) jugador.verChicas(pantalla.m);
        if (pantalla.m.estadoPartida==3) jugador.verPares(pantalla.m);
        if (pantalla.m.estadoPartida==4) jugador.verJuego(pantalla.m);
        
        this.dispose();
}//GEN-LAST:event_botonVerActionPerformed

    private void botonApostarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonApostarActionPerformed
        // TODO add your handling code here
       
       int a =(Integer) this.spinnerApuesta.getValue();
       if (pantalla.m.estadoPartida==1) jugador.apuestaGrande(this.pantalla.m, a);
       if (pantalla.m.estadoPartida==2) jugador.apuestaChicas(this.pantalla.m, a);
       if (pantalla.m.estadoPartida==3) jugador.apuestaPares(this.pantalla.m, a);
       if (pantalla.m.estadoPartida==4) jugador.apuestaJuego(this.pantalla.m, a);
       
       this.dispose();
}//GEN-LAST:event_botonApostarActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                DialogoApuesta dialog = new DialogoApuesta(new javax.swing.JFrame(), true,null,null);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonApostar;
    private javax.swing.JButton botonPasar;
    private javax.swing.JButton botonVer;
    private javax.swing.JLabel jApuesta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel jTexto1;
    private javax.swing.JSpinner spinnerApuesta;
    // End of variables declaration//GEN-END:variables
    
}
